<?php

use Phinx\Migration\AbstractMigration;
use Phinx\Db\Adapter\MysqlAdapter;
class SuperManager extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
   public function up()
    {
        $table = $this->table('managers', array('comment' => '后台总公司管理员表'));
        $table
              ->addColumn('account', 'string', array('limit' => 255,'default' => '','comment' => '账号'))
			  ->addColumn('password', 'string', array('limit' => 255))
              ->addColumn('real_name', 'string', array('limit' => 255,'default' => '','comment' => '管理员姓名'))
			  ->addColumn('email', 'string', array('default' => '','limit' => 255))
			  ->addColumn('manager_name', 'string', array('default' => '','limit' => 255, 'comment' => '管理员姓名'))
			  ->addColumn('profiles', 'string', array('default' => '','limit' => 255, 'comment' => '备注描述'))
			  ->addColumn('identity_num', 'string', array('default' => '','limit' => 255, 'comment' => '身份证号'))
			  ->addColumn('mobile', 'string', array('default' => '','limit' => 255, 'comment' => '联系方式'))
			  ->addColumn('address', 'string', array('default' => '','limit' => 255, 'comment' => '通讯地址'))
			  ->addColumn('status', 'integer', array('default'=>1,'limit' => MysqlAdapter::INT_REGULAR, 'comment' => '管理员状态'))
			  ->addColumn('type', 'integer', array('limit' => MysqlAdapter::INT_REGULAR, 'default' => 1,'comment' => '区别管理员'))
			  ->addColumn('session_id', 'string', array('default' => '','limit' => 255, 'comment' => '用于防止同时登录'))
			  ->addColumn('ip', 'string', array('limit' => 255, 'comment' => '管理员ip地址','null'=>true))
              ->addColumn('created_at', 'timestamp', array('default' => 'CURRENT_TIMESTAMP'))
              ->addColumn('updated_at', 'timestamp', array('null' => true))
              ->addColumn('deleted_at', 'timestamp', array('null' => true))
              ->addIndex('id')
			  ->addIndex('account',array('unique' => true))
              ->save();   
    }
    public function down()
    {
        $this->dropTable('managers');
    }
}
